package com.ChenYaRou.www.dao;

import com.ChenYaRou.www.po.User;

import java.sql.SQLException;
import java.util.List;

/**
 * @ClassName UserDao
 * @Description TODO
 * @Author 86183
 * @Date 2022/4/29 20:10
 * @Version 1.0
 **/
public interface UserDao {
    /**
     * 搜索
     * @param id
     * @return
     * @throws IllegalAccessException
     * @throws SQLException
     * @throws NoSuchFieldException
     * @throws InstantiationException
     */
    User select(Integer id) throws IllegalAccessException, SQLException, NoSuchFieldException, InstantiationException;

    /**
     * 查找一个user by name
     * @param name
     * @return
     * @throws IllegalAccessException
     * @throws SQLException
     * @throws NoSuchFieldException
     * @throws InstantiationException
     */
     User select(String name) throws IllegalAccessException, SQLException,
            NoSuchFieldException, InstantiationException;
    /**
     * 插入 注册
     * @param user user
     * @return 成功与否(>0成功 0 false)
     * @throws  IllegalAccessException
     * @throws SQLException
     */
    int insert(User user) throws IllegalAccessException, SQLException;

    /**
     * 更新user
     * @param newUser 存放更新值的user
     * @param oldUser 原先的user
     * @return 更新条数
     * @throws IllegalAccessException 非法访问
     * @throws SQLException sql异常
     */
    int update(User newUser,User oldUser) throws IllegalAccessException, SQLException;

    /**
     * 查询所有用户,用于管理员解禁封禁用户
     * @return
     * @throws SQLException
     * @throws NoSuchFieldException
     * @throws InstantiationException
     * @throws IllegalAccessException
     */
    List<User> selectAll() throws SQLException, NoSuchFieldException, InstantiationException, IllegalAccessException;
}
